package 设计模式.创建型模式.单例模式.饿汉单例;

/**
 * @author MT
 * @date 2019-11-13 16:37
 */
public class HungrySingleton {

    private String name = "HungrySingleton";

    private static final HungrySingleton instance = new HungrySingleton();

    private HungrySingleton() {
        System.out.println("实例化");
    }

    public static HungrySingleton getInstance() {
        return instance;
    }

    public String getName() {

        System.out.println(name);return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
